home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Go Sit In The Corner 1.0 / source / cdev code / msg dialogs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.3 KB  |  75 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        msg dialogs.c
  4.  
  5. Purpose:    This module handles positioning the error alert (or anything
  6.             else, but that's all we use it for in this control panel)
  7.             in accordance with Human Interface Guidelines.
  8.             
  9.  
  10. Go Sit In The Corner -=- not you, just the cursor
  11. Copyright ©1994, Mark Pilgrim
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program in a file named "GNU General Public License".
  25. If not, write to the Free Software Foundation, 675 Mass Ave,
  26. Cambridge, MA 02139, USA.
  27.  
  28. \**********************************************************************/
  29.  
  30. #include "msg dialogs.h"
  31. #include "cdev globals.h"
  32. #include "GestaltEQU.h"
  33.  
  34. void    PositionDialog(ResType theType, short theID)
  35. {
  36.     Handle                theTemplate;    /* Handle to resource template        */
  37.     long                oldA5;
  38.     QDGlobals            qd;
  39.     GrafPort            gp;
  40.     GrafPtr                savePort;
  41.     register Rect        *theRect;        /* Bounding box of dialog            */
  42.     register short        left;            /* Left side of centered rect        */
  43.     register short        top;            /* Top side of centered rect        */
  44.     
  45.     GetPort(&savePort);
  46.     oldA5 = SetA5((long)&qd.end);
  47.     InitGraf(&qd.thePort);
  48.     OpenPort(&gp);
  49.     SetCursor(&qd.arrow);
  50.     
  51.     theTemplate = GetResource(theType, theID);
  52.     if(theTemplate == 0)
  53.         return;
  54.     theRect = (Rect*) *theTemplate;
  55.     
  56.                                         /* Center horizontally on screen    */
  57.     left = (qd.screenBits.bounds.right - (theRect->right - theRect->left)) / 2;
  58.  
  59.                                         /* Leave twice as much space below    */
  60.                                         /*   as above the rectangle            */    
  61.     top = (qd.screenBits.bounds.bottom - (theRect->bottom - theRect->top)) / 3;
  62.                                         /* Don't put rect under menu bar    */
  63.     if(top < (GetMBarHeight() + 1))
  64.         top = GetMBarHeight() + 1;
  65.  
  66.     theRect->right += left - theRect->left;
  67.     theRect->left = left;
  68.     theRect->bottom += top - theRect->top;
  69.     theRect->top = top;
  70.  
  71.     ClosePort(&gp);
  72.     SetA5(oldA5);
  73.     SetPort(savePort);
  74. }
  75.